#! /usr/bin/python

from zavvi import ZavviParser
from products import Product
from constants import Constants
from database_connection import DBConnection

#Male Clothing
link_male_clothing = [ 'http://www.zavvi.com/clothing/men/clothing/product-types/jackets-waistcoats.list',
                        'http://www.zavvi.com/clothing/men/clothing/product-types/hoodies.list',
                        'http://www.zavvi.com/clothing/men/clothing/product-types/shirts.list',
                        'http://www.zavvi.com/clothing/men/clothing/product-types/shorts.list',
                        'http://www.zavvi.com/clothing/men/clothing/product-types/jeans.list']
#Female Clothing
link_female_clothing = ['http://www.zavvi.com/clothing/women/clothing/product-types/dresses.list',
        'http://www.zavvi.com/clothing/women/clothing/product-types/jackets-coats.list',
        'http://www.zavvi.com/clothing/women/clothing/product-types/jeans-and-trousers.list',
        'http://www.zavvi.com/clothing/women/clothing/product-types/t-shirts-tops.list',
        'http://www.zavvi.com/clothing/women/clothing/product-types/skirts-and-shorts.list']

link_books = 'http://www.zavvi.com/books/latest-releases.list'
link_music = 'http://www.zavvi.com/cd/offers.list'
link_movies = 'http://www.zavvi.com/cd/offers.list'

link_electro = [#'http://www.zavvi.com/technology/headphones-earphones.list',
        'http://www.zavvi.com/technology/audio.list',
        'http://www.zavvi.com/technology/ipods-mp3-mp4.list',
        'http://www.zavvi.com/technology/cameras-photo-accessories.list',
        'http://www.zavvi.com/technology/home-entertainment.list',
        'http://www.zavvi.com/technology/pc-laptops.list',
        'http://www.zavvi.com/technology/ipads-tablets-ereaders.list',
        'http://www.zavvi.com/technology/homeware-appliances.list'
        ]
link_toys = 'http://www.zavvi.com/toys/best-selling-toys.list'

if __name__ == "__main__":
    prod = Product("my_title", "ema", "vera", "gabi", 2)
    prod.printProduct()
    """
    #TESTING Purpose:
    link = 'http://www.zavvi.com/books/dvd-book-of-dogs/9964261.html'
    zavy = ZavviParser(link, Constants.books, 15, 70, 'M/F')
    product, attrs = zavy.download_content(link)
    conn = DBConnection("localhost", "root", "sac_recomandari", "sac_recomandari")
    conn.add_item_to_cadouri_table(product)
    for el in attrs:
        conn.add_item_to_gift_attrs_table(el)
    conn.closeConn() 
    import pdb; pdb.set_trace()
    """
    """
    """
    "Male jackets"
    for link in link_male_clothing:
        zavy = ZavviParser(link, Constants.cloths, 15, 70, 'M')
        zavy.parse_links()
    "Female jackets"
    for link in link_female_clothing:
        zavy = ZavviParser(link, Constants.cloths, 15, 70, 'F')
        zavy.parse_links()
    "Books"
    zavy = ZavviParser(link_books, Constants.books, 10, 70, 'M/F')
    zavy.parse_links()
    "Music"
    zavy = ZavviParser(link_music, Constants.music, 15, 70, 'M/F')
    zavy.parse_links()
    "Movies"
    zavy = ZavviParser(link_movies, Constants.movies, 15, 70, 'M/F')
    zavy.parse_links()
    "Electronics"
    for link in link_electro:
        zavy = ZavviParser(link, Constants.electronics, 21, 70, 'M/F')
        zavy.parse_links()
    "Toys"
    zavy = ZavviParser(link_toys, Constants.toys, 21, 70, 'M/F')
    zavy.parse_links()


    conn = DBConnection("localhost", "root", "sac_recomandari", "sac_recomandari")
    #conn.add_item_to_cadouri_table(prod)
    id = conn.get_all_attrs()
    conn.closeConn()
    print "ID for %s is %s"%(Constants.cloths, id)

